package com.zlm.user.emp.controller;

import com.zlm.common.base.BaseController;
import com.zlm.common.constants.CodeConstants;
import com.zlm.common.dto.JsonResultDto;
import com.zlm.user.emp.service.SysActivationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 验证码controller
 * @Author: duyufu
 * @Date: 2019/4/22 13:04
 */
@RestController
@RequestMapping("/activation")
public class SysActivationController extends BaseController {

    @Autowired
    private SysActivationService sysActivationService;

    /**
     * 发送验证码
     * @param mobile
     * @return
     */
    @GetMapping(value = "/sendActivation")
    public JsonResultDto sendActivation(String mobile) {
        try {
            sysActivationService.sendActivation(mobile);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return fail(e.getMessage());
        }
    }

    /**
     * 校验验证码
     * @param activationCode
     * @param mobile
     * @return
     */
    @GetMapping(value = "/checkActivation")
    public JsonResultDto checkActivation(String activationCode, String mobile) {
        try {
            sysActivationService.checkActivation(activationCode,mobile);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return fail(e.getMessage());
        }
    }


}
